Ext.define('AM.view.EmpCoffersView', {
		extend: 'Ext.grid.Panel',
		alias : 'widget.empCoffersView',
		store : 'EmpCoffersStore',
		border:false,
		columnLines:true,
//		selModel : Ext.create('Ext.selection.CheckboxModel'), 
		selModel: {
	        injectCheckbox: 0,
	        mode: "SIMPLE"    //"SINGLE"/"SIMPLE"/"MULTI"
	     
   		 },
   		selType: "checkboxmodel",
    	dockedItems: [{
        xtype: 'pagingtoolbar',
        dock: 'bottom',
        store : 'EmpCoffersStore',
        displayInfo: true
    }],
		columns: [	
			        {text: '序号',  xtype: 'rownumberer',width:50,align:'center',tdCls:'background-color: #8EE5EE;'},
			      // new Ext.grid.RowNumberer({header:"序号",width:50, align:'center',renderer:function(value, cellmeta, record, rowIndex, columnIndex, store){ return '<font color=blue></font><span style="color:red;">' + (rowIndex+1) + '</span>';}}),
			        { text: '姓名',  dataIndex: 'name',  width:80,align:'center'},
			        { text: '科室',dataIndex: 'dept', width:120,align:'center'},
			        { text: '岗位胜任系数',dataIndex: 'postCompetent', width:100,align:'center'},
			        { text: '岗位管理系数',dataIndex: 'postManager', width:100,align:'center'},
			        { text: '岗位系数',dataIndex: 'postcoffe', width:100,align:'center'},
			        { text: '绩效系数',dataIndex: 'finaceCoffe', width:100,align:'center'},
			        { text: '人员ID', dataIndex: 'id',width:80,align:'center',hidden:true}
			     ],
			   tbar: [
					
					  { xtype: 'button', text: '修改',handler: editGeneralEmp,icon:'Ext/restful/images/user_edit.png'},
					  {
					     xtype : "combobox",
					     allowBlank:false,
					     labelAlign :"right",
						 fieldLabel: '选择科室',
						 store :Ext.create('AM.store.TargetDepartStore'),
						 displayField: 'name',
						 valueField: 'id',
						 id:'search_GeneralEmp',
					     width:300
					  },
					  { xtype: 'button', text: '查询',handler: searchGeneralEmp,icon : 'Ext/restful/images/find.png'
					  }
					]
})
function searchGeneralEmp() {
		   var grid=this.ownerCt.ownerCt;
			var depart= Ext.getCmp('search_GeneralEmp').getValue();
	       //此处为加载条件
		  grid.getStore().on('beforeload', function (store, options) {
		  	
		              var new_params = {serchdepartment:depart}
		                Ext.apply(store.proxy.extraParams, new_params);
		       });
	
		grid.getStore().reload();
					
}
function editGeneralEmp() {
		  var myform1= new Ext.form.Panel({
			        layout : "form",
			         bodyPadding: 25,
			         labelWidth : 65,
			        items: [{
			        	
				      	    xtype : "numberfield",
				      	    labelAlign :"right",
				            fieldLabel: '岗位系数',
				            allowBlank:false,
				            name: 'postcoffe',
						    minValue: 0
			        },{
			   		 	
				      	    xtype : "numberfield",
				      	    labelAlign :"right",
				            fieldLabel: '岗位管理系数',
				            allowBlank:false,
				            name: 'postManager',
						    minValue: 0
							
			   		 },{
				      	    xtype : "numberfield",
				      	    labelAlign :"right",
				            fieldLabel: '绩效系数',
				            allowBlank:false,
				            name: 'finaceCoffe',
						    minValue: 0
						
			        },{
	        			xtype : "numberfield",
			      	    labelAlign :"right",
			            fieldLabel: 'ID',
			            allowBlank:false,
			            name: 'id',
					    minValue: 0,
					    hidden:true
			        		
			   		 }]
     	
		 })
			var grid=this.ownerCt.ownerCt;
			var win = new Ext.Window({
				title : "修改员工系数",
				width : 400,
				height : 300,
				frame:true,
				layout:'fit',
				items : [ myform1
							],
				buttons : [{
							text : "确定",
							handler : function() {
								win.getComponent(0).getForm().submit({
											    url : 'employees_editGeneralEmp',
											    success : function() {
												Ext.Msg.alert('提示', '修改成功');
												win.close();
												grid.getStore().reload();
												grid.getSelectionModel().deselectAll();
											},
											failure : function() {
												Ext.Msg.alert('错误', '添加失败');
											},
											waitMsg : "请稍后，正在保存。。。。"
	
										});
							}
						}, {
							text : "重置",
							handler : function() {
								win.getComponent(0).getForm().reset();
							}
						}, {
							text : "取消",
							handler : function() {
								win.close();
											
							}
						}]
			});
		
		var selections = grid.getSelectionModel().getSelection();
						if(selections.length==0){
							Ext.MessageBox.alert("提示","请选择要编辑的一行！");
						}else if (selections.length > 1) {
							Ext.MessageBox.alert("提示", "请检查您是否选中了多行！");
							return;
						} else{
							var record = selections[0];
						//这里是修改操作的实现部分
							win.getComponent(0).getForm().loadRecord(record);
							win.show();
						}
 }